package registnet.base.summary.honors;

import java.util.List;

import registnet.base.Form5;
import registnet.base.source.Form5Source;
import registnet.base.student.Student;
import registnet.dao.StudentPeer;

public class HonorRollSource implements IHonoraryStudentsSource{

	private int year;
	private int semester;
	private HonorRoll honorRoll;
	
	public HonorRollSource(int semester, int year){
		this.semester = semester;
		this.year = year;
		this.load();
	}
	
	public void load(){
		this.honorRoll = new HonorRoll(this.semester, this.year);
		StudentPeer sp = new StudentPeer();
		List<registnet.dao.Student> students = sp.getAllStudents();
		for(int i=0; i<students.size(); i++){
			try{
				registnet.dao.Student DAOStudent = students.get(i);
				Student student = new Student(DAOStudent.getStudentNumber());
				student.setFirstName(DAOStudent.getFirstName());
				student.setMiddleName(DAOStudent.getMiddleName());
				student.setLastName(DAOStudent.getLastName());
				student.setSex(DAOStudent.getSex());
				student.setCollegeCode(DAOStudent.getCurriculum().getDegreeCourse().getCollege().getCollegeCode());
				student.setDegreeProgram(DAOStudent.getCurriculum().getDegreeCourse().getDegreeCode());
				Form5 form5 = new Form5Source(student.getStudentNumber(), this.semester, this.year).getForm5();
				double GWA = form5.getGWA();
				if(GWA < 2 && GWA > 1.75)
					this.honorRoll.add(student, GWA);
			}catch(Exception e){}
		}
		
	}
	
	public IHonoraryStudents getHonoraryStudents(){
		return this.honorRoll;
	}
	
}
